* build_treatment.do	JEP		01/23/15
* This file builds on prelim_est*.do, builds a program to generate the treatments

* 1. Choose a sample and a measure
* 2. Calculate minimum wage measures
* 3. Create treatment variables and trends
* 4. Run regressions

*************************** Change log ********************************** 

/*
*/

cap program drop mytreatment
program mytreatment
	syntax, posts(string) mw(varname) wage(varname) [limp(numlist min=1) mw_w(varname)]
	
	* Post period
	gen post = (time>=`posts')
	* Treatment
	gen treat=`mw'*post
	* Log wage
	gen lw=log(`wage')

	* Binary breaking
	preserve
	di "Unweighted"
	collapse (firstnm) `mw', by(ciudad)
	list
	restore
	
	if "`mw_w'"!="" {
		preserve
		di "Weighted"
		collapse (firstnm) `mw_w', by(ciudad)
		list
		restore
	}
	
	* Low impact: Pasto Barranquilla Cali
	* High impact:
	if "`limp'"!="" {
		gen limp=0
		foreach n in `limp' {
			replace limp=1 if ccode==`n'
		}
		gen himp=!limp
		gen treat2=himp*post
	}
end

